﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BattleFury.Lib.Graphics
{
	public abstract class Entity
		: IEntity
	{
		public bool IsEnabled { get; set; }
		public bool IsVisible { get; set; }
        //public Engine Engine { get; set; }
		public Texture2D Texture { get; set; }
		public Vector2 Position { get; set; }
		public Vector2 Size { get; set; }

		public SpriteBatch SpriteBatch
		{
			get { return RenderEngine.Get().SpriteBatch; }
		}

		public Rectangle Bounds
		{
			get
			{
				return new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y);
			}
		}

		protected Entity()
		{
			Size = Vector2.One;
			Position = Vector2.Zero;
			IsEnabled = true;
			IsVisible = true;
		}

		public virtual void Update(GameTime gameTime)
		{
			if (!IsEnabled) return;
		}

		public virtual void Draw(GameTime gameTime)
		{
			if (!IsVisible) return;
			if (Texture == null) return;

			SpriteBatch.Draw(Texture, Bounds, Color.White);
		}
	}
}